<%@ page contentType="text/html; charset=utf-8"%>
<%@ taglib prefix="s" uri="/struts-tags"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
	<head>
		<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
		<link rel="stylesheet" type="text/css" href="<%=request.getContextPath()%>/resource/css/default.css" />
		<link rel="stylesheet" type="text/css" href="${contextPath}/resource/tree/zTreeStyle/zTreeStyle.css" />
		<script type="text/javascript" src="${contextPath}/resource/tree/jquery-1.4.2.js"></script>
		<script type="text/javascript" src="${contextPath}/resource/tree/jquery.ztree-2.6.js"></script>
		
		<script language="JavaScript">
            	function submitFrom(fm){
	  if(document.getElementById("phoneInfo.piPp").value ==""){
			alert("品牌不能为空 !");
			return;
		}
		if(document.getElementById("phoneInfo.piJx").value ==""){
			alert("机型不能为空!");
			return;
		}
		if(document.getElementById("phoneInfo.piJxid").value ==""){
			alert("机型Id不能为空!");
			return;
		}
		
		if(document.getElementById("phoneInfo.piCpid").value ==""){
			alert("产品Id不能为空 !");
			return;
		}
		if(document.getElementById("phoneInfo.piCp").value ==""){
			alert("产品不能为空!");
			return;
		}
		if(document.getElementById("phoneInfo.piZzs").value ==""){
			alert("制造商不能为空!");
			return;
	    }
	  if(document.all.newZYtext1.style.color == "red"  ){
	        return false;
	  }
	  if(document.all.newZYtext2.style.color == "red" ){
	        return false;
	  }
	  if(document.all.newZYtext3.style.color == "red" ){
	        return false;
	  }
	  if(document.all.newZYtext4.style.color == "red" ){
	        return false;
	  }
	  if(document.all.newZYtext5.style.color == "red" ){
	        return false;
	  }
	  if(document.all.newZYtext6.style.color == "red" ){
	        return false;
	  }
	  fm.submit();
	}
	
	//品牌验证
	function new_professionText1(value){
	var brand=document.getElementById("phoneInfo.piPp").value;
	if(getLength(brand)<=0){
		document.all.newZYtext1.style.color = "red";
		document.all.newZYtext1.innerHTML = "此处不能为空";
	}else if(getLength(brand)>40){
		document.all.newZYtext1.style.color = "red";
		document.all.newZYtext1.innerHTML = "超过40个字符";
	}else if(stripscript(brand)!=null){
		document.all.newZYtext1.style.color = "red";
		document.all.newZYtext1.innerHTML = "手机品牌不能输入特殊字符";
	}else if(getLength(brand)>0&&getLength(brand)<=40){
		document.all.newZYtext1.style.color = "green";
		document.all.newZYtext1.innerHTML = "正确";
	}
}

//机型验证
function new_professionText2(value){
	var model=document.getElementById("phoneInfo.piJx").value;
	if(getLength(model)<=0){
		document.all.newZYtext2.style.color = "red";
		document.all.newZYtext2.innerHTML = "此处不能为空";
	}else if(getLength(model)>40){
		document.all.newZYtext2.style.color = "red";
		document.all.newZYtext2.innerHTML = "超过40个字符";
	}else if(stripscript(model)!=null){
		document.all.newZYtext2.style.color = "red";
		document.all.newZYtext2.innerHTML = "机型不能输入特殊字符";
	}
	else if(getLength(model)>0&&getLength(model)<=40){
		document.all.newZYtext2.style.color = "green";
		document.all.newZYtext2.innerHTML = "正确";
	}
}
//机型Id验证
function new_professionText3(value){
	var vendorid=document.getElementById("phoneInfo.piJxid").value;
	if(getLength(vendorid)<=0){
		document.all.newZYtext3.style.color = "red";
		document.all.newZYtext3.innerHTML = "此处不能为空";
	}else if(getLength(vendorid)>20){
		document.all.newZYtext3.style.color = "red";
		document.all.newZYtext3.innerHTML = "超过20个字符";
	}else if(stripscript(vendorid)!=null){
		document.all.newZYtext3.style.color = "red";
		document.all.newZYtext3.innerHTML = "机型 ID不能输入特殊字符";
	}else if(strchar(vendorid)!=null){
		document.all.newZYtext3.style.color = "red";
		document.all.newZYtext3.innerHTML = "机型 ID只能是英文或数字";
	}
	else if(getLength(vendorid)>0&&getLength(vendorid)<=20){
		document.all.newZYtext3.style.color = "green";
		document.all.newZYtext3.innerHTML = "正确";
	}
}
//产品Id验证
function new_professionText4(value){
	var productid=document.getElementById("phoneInfo.piCpid").value;
	var len=getLength(productid);
	if(len<=0){
		document.all.newZYtext4.style.color = "red";
		document.all.newZYtext4.innerHTML = "此处不能为空";
	}else if(len>20){
		document.all.newZYtext4.style.color = "red";
		document.all.newZYtext4.innerHTML = "超过20个字符";
	}else if(stripscript(productid)!=null){
		document.all.newZYtext4.style.color = "red";
		document.all.newZYtext4.innerHTML = "产品 ID不能输入特殊字符";
	}else if(strchar(productid)!=null){
		document.all.newZYtext4.style.color = "red";
		document.all.newZYtext4.innerHTML = "产品 ID只能是英文或数字";
	}
	else if(len>0&&len<=20){
		document.all.newZYtext4.style.color = "green";
		document.all.newZYtext4.innerHTML = "正确";
	}
}
function new_professionText5(value){
	var product=document.getElementById("phoneInfo.piCp").value;
	var len=getLength(product);
	if(len<=0){
		document.all.newZYtext5.style.color = "red";
		document.all.newZYtext5.innerHTML = "此处不能为空";
	}else if(len>40){
		document.all.newZYtext5.style.color = "red";
		document.all.newZYtext5.innerHTML = "超过40个字符";
	}else if(stripscript(value)!=null){
		document.all.newZYtext5.style.color = "red";
		document.all.newZYtext5.innerHTML = "产品不能输入特殊字符";
	}
	else if(len>0&&len<=40){
		document.all.newZYtext5.style.color = "green";
		document.all.newZYtext5.innerHTML = "正确";
	}
}
//制造商验证
function new_professionText6(value){
	var manufacturer=document.getElementById("phoneInfo.piZzs").value;
	var len=getLength(manufacturer);
	if(len<=0){
		document.all.newZYtext6.style.color = "red";
		document.all.newZYtext6.innerHTML = "此处不能为空";
	}else if(len>40){
		document.all.newZYtext6.style.color = "red";
		document.all.newZYtext6.innerHTML = "超过40个字符";
	}else if(stripscript(manufacturer)!=null){
		document.all.newZYtext6.style.color = "red";
		document.all.newZYtext6.innerHTML = "制造商不能输入特殊字符";
	}
	else if(len>0&&len<=40){
		document.all.newZYtext6.style.color = "green";
		document.all.newZYtext6.innerHTML = "正确";
	}
}




function stripscript(s) 
{ 
	if(/[~#^$@%&!*‘'#$￥！@#￥%……&*（） 《》<>-]/gi.test(s)){
		return "1";
	}
	return null;
} 

function strchar(strName){
	if (/[^a-zA-Z0-9]/gi.test(strName)) {
	   return "1";
	}
return null;
}

function getLength(str) {
	if (str == null || str == "") {
		return 0;
	} else {
		var len = str.length;
		var reLen = 0;
		for ( var i = 0; i < len; i++) {
			if (str.charCodeAt(i) < 27 || str.charCodeAt(i) > 126) {
				reLen += 2;
			} else {
				reLen++;
			}
		}
		return reLen;
	}
}
</script>
</head>
<body>
		<s:form action="phoneInfoAction_update.do" namespace="/phone" method="post" onsubmit="getCheckedNodesLength_lh()">
			<table class="menu_table">
				<tr>
					<th>
						<a href="phoneInfoAction_list.do">手机信息管理</a>&gt;&gt;编辑手机信息
					</th>
				</tr>
			</table>
			<div class="listtable">
				<div class="secondDiv">
					<table class="form_table">
						<tr>
							<th width="20%">
								品牌
							</th>
							<td width="15%">
									<s:textfield name="phoneInfo.piPp" id="phoneInfo.piPp" 
									onblur="new_professionText1(this.value)" />
								<span class="txtblue" id="resultadminUser">*</span>
								<span id="newZYtext1"
									style="color: 666666"></span>
							</td>
						</tr>
						 <tr>
							<th width="20%">
							   机型
							</th>
							<td width="35%">
								<s:textfield  name="phoneInfo.piJx" id="phoneInfo.piJx" onblur="new_professionText2(this.value)"></s:textfield>
								<span class="txtblue" id="resultadminUser">*</span>
								<span id="newZYtext2"
									style="color: 666666"></span>
							</td>
						</tr>
						<tr>
							<th>
								机型ID
							</th>
							<td>
								<s:textfield name="phoneInfo.piJxid" id="phoneInfo.piJxid"
									 onblur="new_professionText3(this.value)"></s:textfield>
									<span class="txtblue" id="resultadminUser">*</span>
									<span id="newZYtext3"
									style="color: 666666"></span>
							</td>
							
						</tr>
						<tr>
							<th>
								产品ID
							</th>
							<td>
								<s:textfield name="phoneInfo.piCpid" id="phoneInfo.piCpid" 
								 onblur="new_professionText4(this.value)" />
									<span class="txtblue" id="resultadminUser">*</span>
									<span id="newZYtext4"
									style="color: 666666"></span>
							</td>
						</tr>
						<tr>
							<th>
								产品
							</th>
							<td>
								<s:textfield name="phoneInfo.piCp" id="phoneInfo.piCp" 
								 onblur="new_professionText5(this.value)"/>
									<span class="txtblue" id="resultadminUser">*</span>
									<span id="newZYtext5"
									style="color: 666666"></span>
							</td>
						</tr>
						<tr>
							<th>
								制造商
							</th>
							<td>
								<s:textfield name="phoneInfo.piZzs" id="phoneInfo.piZzs" onblur="new_professionText6(this.value)" />
									<span class="txtblue" id="resultadminUser">*</span>
									<span id="newZYtext6"
									style="color: 666666"></span>
							</td>
						</tr>
					</table>
					
		<table width="50%" border="0" align="center" cellpadding="3" cellspacing="1">
			<s:token></s:token>
		    <tr>
		      <td align="center"  >
		      <div align="center">
		       	<input type="button" value="" class="apply_style" align="middle" onclick="submitFrom(this.form);"/>
		        <input type="button" onclick="javascript:location='phoneInfoAction_list.do'" class="back_style"  />
		        <input type="reset" id="重置 " class="reset_style" value=""/>
		       </div>
		       </td>
		    </tr>
		</table>
				</div>
			</div>
		</s:form>
	</body>
</html>
